﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CardGame
{
    public class cl_0423_FinalState : cl_0423_AbstractState
    {
        public cl_0423_FinalState(cl_0423_AbstractState state)
        {
            this.acc = state.acc;
            this.point = state.getPoint();
            this.stateName = "骨灰";
            this.peekCards();
        }

        public void doubleScore(int score)
        {
            this.point += score;
            Console.WriteLine("胜利，双倍积分叠加功能");
        }

        public override void play(string outcome)
        {
            if (outcome == "win")
            {

                this.point += acc.score;
                this.doubleScore(acc.score);
                Console.WriteLine(acc.getName() + "游戏胜利,增加" + acc.score * 2 + "分");
                checkState();
                Console.WriteLine("剩余积分:" + this.point + "当前级别:" + acc.getState().getStateName());
            }
            else
            {
                Console.WriteLine(acc.getName() + "游戏失败,减少" + "10" + "分");
                this.point -= 10;
                checkState();
                Console.WriteLine("剩余积分:" + this.point + "当前级别:" + acc.getState().getStateName());
               
            }
            this.peekCards();
            this.changeCards();
        }

        public void changeCards()
        {
            Console.WriteLine("有换牌功能");
        }

        public void checkState()
        {
            if (point <= 500)
            {
                acc.setState(new cl_0423_ProfessionalState(this));
            }
            else if (point <= 300)
            {
                acc.setState(new cl_0423_SecondaryState(this));
            }
            else if (point <= 100)
            {
                acc.setState(new cl_0423_PrimaryState(this));
            }
        }
        public void peekCards()
        {
            Console.WriteLine("有偷看纸牌功能");
        }
    }
}